<?php
###############   COPYLEFT GPLv3 LICENSE   ###############
##
## JFX Version 0.2.9
## Website Management Software
## www.jfxcms.com
##
## Copyright 2009 GPLv3 - http://www.opensource.org/licenses/gpl-3.0.html
##
## Anthony Gallon
## oi_antz@hotmail.com
##
## Permission is hereby granted to any person having a copy of this software
## to freely use and modify as required so long as the copyright notices
## and branding remain intact.
##
## Full license details available at http://www.jfxcms.com/license
##
###############   COPYLEFT GPLv3 LICENSE   ###############

JFX::checkAdminPermsRedirect('core', 'perm_manage_domains');

$THEME->addBreadcrumb($this->adminUrl.'/domains/', $this->lang('ap_title_domains'));



$domains = $DB->fetchAll("SELECT * FROM {$CONFIG->dbprefix}domains ORDER BY domain_name ASC");
$domainOpts = array();
foreach($domains as $k=>$v){
    $domainOpts[$v['id']] = $v['domain_name'];
}

if(isset($folders) && is_array($folders) && array_key_exists(1, $folders)){
	$folders[1] = str_replace('..', '', $folders[1]);
	if(file_exists($this->dirname.'/actions/domains/'.$folders[1].'.php')){
		require($this->dirname.'/actions/domains/'.$folders[1].'.php');
	}
}























function JFX_Domains_MakeTree($arr, $domain){
    $CONFIG = JFX::registry('config');
    $LANG = JFX::registry('lang');
    $returnString = '';
    foreach($arr as $k=>$v){

        if($v['parent_id']==0) $link = $LANG->getContent('core', 'heading', $v['id']);
        else $link = '<a href="'.$CONFIG->adminUrl.'/domains?domain='.urlencode($domain).'&amp;root-page=1&amp;page='.$v['id'].'" id="page_'.$v['id'].'">'.$LANG->getContent('core', 'heading', $v['id']).'</a>';
        
        if(isset($v['subpages']) && count($v['subpages'])>0){
            $subpages = '<ul>'.JFX_Domains_MakeTree($v['subpages'], $domain).'</ul>';
        }else{
            $subpages = '';
        }
        $returnString .= '<li>'.$link.$subpages.'</li>';
    }

    return $returnString;
}


